/*
 * @Author: 常安民 changanmin1@crdigital.com.cn
 * @Date: 2024-07-30 21:03:55
 * @LastEditors: 常安民 changanmin1@crdigital.com.cn
 * @LastEditTime: 2024-07-30 22:13:56
 * @FilePath: /console-web/mock/standard.js
 * @Description: 差标管理
 * @email:anmin@foxmail.com
 * Copyright (c) 2024 by 华润数科控股有限公司/常安民, All Rights Reserved. 
 */
const standardList =  [
    {
        "id": 1,
        // 所属租户
        "tenantCode": "CRC",
        "tenantName": "数科",
         // 差标编码
         standardCode: "CRC-00"+(1+1),
         // 差标名称
         standardName: "华润管理层"+(1+1),   
         //差标状态
         enabled: 1,
         //描述
         remark:"管理层，包含老干部",
         //更新时间
        "createUser": "admin",
        "createTime": "2024-07-29 03:00:01",
        "updateTime": "2024-07-29 03:00:01",
        "updateUser": "admin",
        train:{
            ordinaryTrain: [],
            highSpeedTrain: [],
            addressOnOff:1,
        }
    },
    {
        "id": 2,
        // 所属租户
        "tenantCode": "CRC",
        "tenantName": "数科",
         // 差标编码
         standardCode: "CRC-00"+(2+1),
         // 差标名称
         standardName: "华润管理层"+(2+1),   
         //差标状态
         enabled: 1,
         //描述
         remark:"管理层，包含老干部",
         //更新时间
        "createUser": "admin",
        "createTime": "2024-07-29 03:00:01",
        "updateTime": "2024-07-29 03:00:01",
        "updateUser": "admin",
        train:{
            ordinaryTrain: ['硬座'],
            highSpeedTrain: ['一等座'],
            addressOnOff:1,
        }
    }
];

export default {
    'POST /apis/mgt/standardQueryPage': (req, res) => { 
        const {commonPageDTO:{ currentPage , pageSize },sortDTO:{fieldName,orderBy},pageNum,condition} = req.body;
   
        return res.json({ 
            "code": "0",
            "message": "SUCCESS",
            "data": {
                "records":standardList,
                "total": 28,
                "size": 10,
                "current": 1,
                "orders": [],
                "optimizeCountSql": true,
                "searchCount": true,
                "countId": null,
                "maxLimit": null,
                "pages": 3
            },
            "traceId": null,
            "success": true 
        });
    },
    'POST /apis/mgt/standardInfo': (req, res) => { 
        const {id} = req.body; 
        const standard = standardList.find(item => item.id == id);
        if(standard){
            return res.json({ 
                "code": "0",
                "message": "SUCCESS",
                "data": standard,
                "traceId": null,
                "success": true 
            });
        }else{
            return res.json({ 
                "code": "1",
                "message": "error",
                "data": null ,
                "traceId": null,
                "success": false 
            });
        }
    },
    'POST /apis/mgt/addStandardInfo': (req, res) => {  
        const item = req.body; 
        
        item.standardCode = item.tenantCode+'_'+standardList.length;
        item.id = Date.now();
        const a = new Date();
        item.updateTime = a.toLocaleString();
        standardList.push(item);
        return res.json({ 
            "code": "0",
            "message": "SUCCESS",
            "data":item.id,
            "traceId": null,
            "success": true 
        });
    },
    'POST /apis/mgt/updateStandardInfo': (req, res) => { 
        const standard = req.body;
        const _standard = standardList.find(item=>{
            if(item.id == standard.id){
              Object.assign(item,standard);
              return true;
            }
            return false;
        })
        return res.json({ 
            "code": "0",
            "message": "SUCCESS",
            "data":  _standard,
            "traceId": null,
            "success": true 
        });
    },
    'POST /apis/mgt/delStandardInfo': (req, res) => { 
        const {id} = req.body; 
        const delIndex = standardList.findIndex(item=>item.id == id);
        standardList.splice(delIndex,1)
        return res.json({ 
            "code": "0",
            "message": "SUCCESS",
            "data":  delIndex,
            "traceId": null,
            "success": true 
        });
    },
}